package BIJiaoQi;

import sun.text.UCompactIntArray;

public class Person implements Comparable{
    private int id;
    private String name;
    private int age;
    private String city;

    public Person(int id, String name, int age, String city) {
        this.id = id;
        this.name = name;
        this.age = age;
        this.city = city;
    }
    public Person()
    {

    }

    @Override
    public String toString() {
        return "Person{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", city='" + city + '\'' +
                '}';
    }
/*
当当前对象小于传入对象时，就要返回值是1则降序（就是当前对象大），0就相等，当当前对象大于传入对象时就要返回值是-1升序（就是传入对象大）
 */
    @Override
    public int compareTo(Object o) {
        Person input = (Person) o;
        int result=this.id<input.id?1:(this.id==input.id?0:-1);
        //降序
        //5，4
        if(result==0)
            result=this.name.compareTo(input.name);//名字升序
        {
        }
        return result;

    }
}
